<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="impress,js框架," />





  <link rel="alternate" href="/atom.xml" title="jackfred的博客" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.2" />






<meta name="description" content="快过年了，作为一个前端工程师，要写年终总结ppt啥的了，这里介绍一个炫酷的js框架，用网页实现比ppt还炫酷的效果。">
<meta property="og:type" content="article">
<meta property="og:title" content="impress简易教程">
<meta property="og:url" content="https://zk-.github.io/2016/12/23/impress简易教程/index.html">
<meta property="og:site_name" content="jackfred的博客">
<meta property="og:description" content="快过年了，作为一个前端工程师，要写年终总结ppt啥的了，这里介绍一个炫酷的js框架，用网页实现比ppt还炫酷的效果。">
<meta property="og:updated_time" content="2016-12-23T03:08:52.134Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="impress简易教程">
<meta name="twitter:description" content="快过年了，作为一个前端工程师，要写年终总结ppt啥的了，这里介绍一个炫酷的js框架，用网页实现比ppt还炫酷的效果。">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 6342361719439885000,
      author: '作者'
    }
  };
</script>

  <title> impress简易教程 | jackfred的博客 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?b3de569bd7de0e2a0f7fdae181ff03da";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">jackfred的博客</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">人啊,就是需要一点亮剑精神</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
            分类
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="#" class="popup-trigger">
          
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                impress简易教程
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-12-23T10:26:37+08:00" content="2016-12-23">
              2016-12-23
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/博客/" itemprop="url" rel="index">
                    <span itemprop="name">博客</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/12/23/impress简易教程/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/12/23/impress简易教程/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>快过年了，作为一个前端工程师，要写年终总结ppt啥的了，这里介绍一个炫酷的js框架，用网页实现比ppt还炫酷的效果。<br><a id="more"></a></p>
<h1 id="效果展示"><a href="#效果展示" class="headerlink" title="效果展示"></a>效果展示</h1><p><a href="https://juzoom.github.io/" target="_blank" rel="external">聚众编码！</a></p>
<h1 id="原理介绍"><a href="#原理介绍" class="headerlink" title="原理介绍"></a>原理介绍</h1><p>这里用的impress.js框架，这个框架帮你做到的是，把指定的div标签变成一个个独占整个页面的元素，通过给出的接口进行定位，是三维上的定位！然后通过js控制把每个元素转到当前窗口来，在浏览器支持css3的情况下使用css3的动画功能来实现的。</p>
<h1 id="项目地址和文档地址"><a href="#项目地址和文档地址" class="headerlink" title="项目地址和文档地址"></a>项目地址和文档地址</h1><p><a href="https://github.com/impress/impress.js" target="_blank" rel="external">项目地址</a><br><a href="https://github.com/impress/impress.js/blob/master/DOCUMENTATION.md" target="_blank" rel="external">文档地址</a></p>
<h1 id="起步"><a href="#起步" class="headerlink" title="起步"></a>起步</h1><p>首先要引入impress.js文件，和普通的js引入方式是一样的<br>然后在文档里加入代码<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;div id=&quot;impress&quot;&gt;&lt;/div&gt; //id可以自定义</div></pre></td></tr></table></figure></p>
<p>然后在引入的impress文件下插入这段代码<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">impress( &quot;root&quot; ); //这里是你的id，如果id是impress，则这一步省略</div><div class="line">impress().init();</div></pre></td></tr></table></figure></p>
<h1 id="插入ppt"><a href="#插入ppt" class="headerlink" title="插入ppt"></a>插入ppt</h1><h2 id="基础"><a href="#基础" class="headerlink" title="基础"></a>基础</h2><p>在你指定的根div中间插入ppt类的div<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">&lt;div id=&quot;impress&quot;&gt;</div><div class="line">	&lt;div id=&quot;test&quot; class=&quot;step&quot; data-x=&quot;0&quot; data-y=&quot;0&quot;&gt;</div><div class="line">	    test</div><div class="line">	&lt;/div&gt;</div><div class="line">&lt;/div&gt;</div></pre></td></tr></table></figure></p>
<p>这里div的class必须要有’step’，id可以有可以没有，如果没有，impress就会把你的id默认变成’step-1’这样的。<br>‘data-x’和’data-y’这样的就是ppt的定位</p>
<h2 id="2D平移"><a href="#2D平移" class="headerlink" title="2D平移"></a>2D平移</h2><p>如果我们再加入一段ppt类的div，页面就可以平移动起来了<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">&lt;div id=&quot;impress&quot;&gt;</div><div class="line">	&lt;div id=&quot;test1&quot; class=&quot;step&quot; data-x=&quot;0&quot; data-y=&quot;0&quot;&gt;</div><div class="line">	    test1</div><div class="line">	&lt;/div&gt;</div><div class="line">	&lt;div id=&quot;test2&quot; class=&quot;step&quot; data-x=&quot;1600&quot; data-y=&quot;0&quot;&gt;</div><div class="line">	    test2</div><div class="line">	&lt;/div&gt;</div><div class="line">&lt;/div&gt;</div></pre></td></tr></table></figure></p>
<h2 id="缩放"><a href="#缩放" class="headerlink" title="缩放"></a>缩放</h2><p>我们想加入缩放的话只要加入’data-scale’这个属性就可以了，赋值为数字，越大缩放越大<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&lt;div id=&quot;test&quot; class=&quot;step&quot; data-x=&quot;1600&quot; data-y=&quot;0&quot; data-scale=&quot;3&quot;&gt;</div><div class="line">    test</div><div class="line">&lt;/div&gt;</div></pre></td></tr></table></figure></p>
<h2 id="2D旋转"><a href="#2D旋转" class="headerlink" title="2D旋转"></a>2D旋转</h2><p>如果想做旋转效果的ppt，加入’data-rotate’属性，赋值范围0~360<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&lt;div id=&quot;test&quot; class=&quot;step&quot; data-x=&quot;1600&quot; data-y=&quot;0&quot; data-rotate=&quot;90&quot; data-scale=&quot;3&quot;&gt;</div><div class="line">    test</div><div class="line">&lt;/div&gt;</div></pre></td></tr></table></figure></p>
<h2 id="3D定位"><a href="#3D定位" class="headerlink" title="3D定位"></a>3D定位</h2><p>加入’data-z’属性实现3D空间上的定位</p>
<h2 id="3D翻滚"><a href="#3D翻滚" class="headerlink" title="3D翻滚"></a>3D翻滚</h2><p>可能最炫酷的效果就是这个了，需要配合3D定位，属性有两个’data-rotate-x’和’data-rotate-y’，分别实现横向和纵向翻滚。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&lt;div id=&quot;test&quot; class=&quot;step&quot; data-x=&quot;6200&quot; data-y=&quot;4300&quot; data-z=&quot;-100&quot; data-rotate-x=&quot;-40&quot; data-rotate-y=&quot;10&quot;&gt;</div><div class="line">    test</div><div class="line">&lt;/div&gt;</div></pre></td></tr></table></figure></p>
<h1 id="方法接口"><a href="#方法接口" class="headerlink" title="方法接口"></a>方法接口</h1><p>impress还给出了方法接口</p>
<h2 id="init"><a href="#init" class="headerlink" title=".init()"></a>.init()</h2><p>初始化用途<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">var api = impress();</div><div class="line">api.init();</div></pre></td></tr></table></figure></p>
<h2 id="next"><a href="#next" class="headerlink" title=".next()"></a>.next()</h2><p>切换下一个ppt的功能<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">var api = impress();</div><div class="line">api.init();</div><div class="line">api.next(); //使用方法下面都一样</div></pre></td></tr></table></figure></p>
<h2 id="prev"><a href="#prev" class="headerlink" title=".prev()"></a>.prev()</h2><p>切换前一个ppt的功能</p>
<h2 id="goto-stepIndex-stepElementId-stepElement-duration"><a href="#goto-stepIndex-stepElementId-stepElement-duration" class="headerlink" title=".goto( stepIndex | stepElementId | stepElement, [ duration ] )"></a>.goto( stepIndex | stepElementId | stepElement, [ duration ] )</h2><p>切换到指定ppt的功能，接受id和数字和dom元素，还能配置切换时间</p>
<h1 id="事件监听接口"><a href="#事件监听接口" class="headerlink" title="事件监听接口"></a>事件监听接口</h1><p>impress给出了两个事件监听接口<br>impress:stepenter 切入当前ppt的事件<br>impress:stepleave 切出当前ppt的事件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">var rootElement = document.getElementById( &quot;impress&quot; );</div><div class="line">rootElement.addEventListener( &quot;impress:stepenter&quot;, function() &#123;</div><div class="line">	var currentStep = document.querySelector( &quot;.present&quot; );</div><div class="line">	console.log( &quot;Entered the Step Element &apos;&quot; + currentStep.id + &quot;&apos;&quot; );</div><div class="line">&#125;);</div><div class="line"></div><div class="line">rootElement.addEventListener( &quot;impress:stepleave&quot;, function(event) &#123;</div><div class="line">	var currentStep = event.target</div><div class="line">	console.log( &quot;Left the Step Element &apos;&quot; + currentStep.id + &quot;&apos;&quot; );</div><div class="line">&#125;);</div></pre></td></tr></table></figure></p>
<h1 id="样式"><a href="#样式" class="headerlink" title="样式"></a>样式</h1><p>impress还给出了一些样式特效，具体的读者自己去文档看吧！我就偷懒啦！</p>

      
    </div>

    <div>
      
        
      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/impress/" rel="tag">#impress</a>
          
            <a href="/tags/js框架/" rel="tag">#js框架</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/11/30/github以及github-page访问缓慢的解决办法/" rel="next" title="github以及github page访问缓慢的解决办法">
                <i class="fa fa-chevron-left"></i> github以及github page访问缓慢的解决办法
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/01/06/用脚本锁住百度云下载加速倒计时-从而实现无限加速/" rel="prev" title="用脚本锁住百度云下载加速倒计时,从而实现无限加速">
                用脚本锁住百度云下载加速倒计时,从而实现无限加速 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2016/12/23/impress简易教程/"
     data-title="impress简易教程"
     data-content=""
     data-url="https://zk-.github.io/2016/12/23/impress简易教程/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2016/12/23/impress简易教程/"
           data-title="impress简易教程" data-url="https://zk-.github.io/2016/12/23/impress简易教程/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="周康" />
          <p class="site-author-name" itemprop="name">周康</p>
          <p class="site-description motion-element" itemprop="description">运动与认知是人生最重要的两件事</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">12</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">2</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">21</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/zk-" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/jackfredzk" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/zhou-kang-46-86" target="_blank" title="Zhihu">
                  
                    <i class="fa fa-fw fa-quote-left"></i>
                  
                  Zhihu
                </a>
              </span>
            
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#效果展示"><span class="nav-number">1.</span> <span class="nav-text">效果展示</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#原理介绍"><span class="nav-number">2.</span> <span class="nav-text">原理介绍</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#项目地址和文档地址"><span class="nav-number">3.</span> <span class="nav-text">项目地址和文档地址</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#起步"><span class="nav-number">4.</span> <span class="nav-text">起步</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#插入ppt"><span class="nav-number">5.</span> <span class="nav-text">插入ppt</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#基础"><span class="nav-number">5.1.</span> <span class="nav-text">基础</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2D平移"><span class="nav-number">5.2.</span> <span class="nav-text">2D平移</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#缩放"><span class="nav-number">5.3.</span> <span class="nav-text">缩放</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2D旋转"><span class="nav-number">5.4.</span> <span class="nav-text">2D旋转</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3D定位"><span class="nav-number">5.5.</span> <span class="nav-text">3D定位</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3D翻滚"><span class="nav-number">5.6.</span> <span class="nav-text">3D翻滚</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#方法接口"><span class="nav-number">6.</span> <span class="nav-text">方法接口</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#init"><span class="nav-number">6.1.</span> <span class="nav-text">.init()</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#next"><span class="nav-number">6.2.</span> <span class="nav-text">.next()</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#prev"><span class="nav-number">6.3.</span> <span class="nav-text">.prev()</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#goto-stepIndex-stepElementId-stepElement-duration"><span class="nav-number">6.4.</span> <span class="nav-text">.goto( stepIndex | stepElementId | stepElement, [ duration ] )</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#事件监听接口"><span class="nav-number">7.</span> <span class="nav-text">事件监听接口</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#样式"><span class="nav-number">8.</span> <span class="nav-text">样式</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">周康</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"jackfred"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
      
      <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
      <script src="/js/src/hook-duoshuo.js"></script>
    
  





  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';                
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = true;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = data.url;
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '' && data_content != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title < 0 && index_content < 0 ){
                                isMatch = false;
                            } else {
                                if (index_content < 0) {
                                    index_content = 0;
                                }
                                if (i == 0) {
                                    first_occur = index_content;
                                }
                            }
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });
                            
                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').mousedown(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>

  

  

  

</body>
</html>
